import com.sun.javafx.robot.FXRobotImage;

import java.util.Comparator;
import java.util.PriorityQueue;

public class Main {
    public static void main(String[] args) {
        PriorityQueue<Integer> priorityQueue=new PriorityQueue<>();
        priorityQueue.offer(6);
        priorityQueue.offer(1);
        priorityQueue.offer(8);
        priorityQueue.offer(7);
        System.out.println(priorityQueue.peek());
    }
}
class Solution {
    public int[] smallestK(int[] arr, int k) {
        int[] ret=new int[k];
        PriorityQueue<Integer> priorityQueue=new PriorityQueue<>(k,new com());
        for (int i = 0; i <k; i++) {
            priorityQueue.offer(arr[i]);
        }
        for (int j = k; j <arr.length; j++) {
            if(arr[j]<priorityQueue.peek()){
                priorityQueue.poll();
                priorityQueue.offer(arr[j]);
            }
        }
        for (int i = 0; i < k; i++) {
            ret[i]=priorityQueue.poll();
        }
        return ret;
    }
}
class com implements Comparator<Integer>{
    @Override
    public int compare(Integer t2, Integer t1) {
        return t1-t2;
    }
}